﻿<%@ Control Language="C#" %>

<My:JSScript Type="Block" runat="server">

function onStatisticFieldDropDownListChanged()
{
	var selectedValue = $("#ComboBoxStatisticFieldTd select").val();
	changeStatisticField(selectedValue);
	
	if (window.SelectionStatisticFilterComboBox)
		window.SelectionStatisticFilterComboBox.setValue("");
}

function changeStatisticField(newValue)
{
	$(".statisticfield").css("display", "none");
	$(".statisticfield-string").css("display", "none");
	$(".statisticfield-datetime").css("display", "none");
	$(".statisticfield-integer").css("display", "none");
	$(".statisticfield-decimal").css("display", "none");
	$(".statisticfield-singleselection").css("display", "none");
	$(".statisticfield-aggregate").css("display", "none");
	
	var optionSelector = String.format("#ComboBoxStatisticFieldTd option[value={0}]", newValue);
	var controlType = $(optionSelector).attr("ControlType");
	if (controlType != null && controlType.trim().length > 0)
	{		
		var displayValue = Ext.isIE7 || Ext.isIE6 ? "block" : "table-row";
		var cssSelectorToDisplay = ".statisticfield-" + controlType.toLowerCase();
		$(".statisticfield").css("display", displayValue);
		$(cssSelectorToDisplay).css("display", displayValue);
		
		var isAggregateProperty = controlType.toLowerCase() == "aggregate";
		$("#RadioButtonListLocationTd :radio").attr("disabled", isAggregateProperty);
		if (isAggregateProperty)
			$("#RadioButtonListLocationTd :radio[value=Column]").attr("checked", true);
		
		if (controlType.toLowerCase() == "singleselection")
			updateComboBoxSelectionDataSource(newValue);
	}
}

function updateComboBoxSelectionDataSource(candidateStatisticPropertyId)
{
	if (!window.SelectionStatisticFilterComboBox) return;
	
	var dataStore = window.SelectionStatisticFilterComboBox.getStore();
	dataStore.setBaseParam("candidateStatisticPropertyId", candidateStatisticPropertyId);
	dataStore.reload();
}

</My:JSScript>

<table cellpadding="0" cellspacing="0" class="table6col">
	<tr>
		<td class="c1"><%=Resources.Statistic.StatisticProperty%>: </td>
		<td id="ComboBoxStatisticFieldTd" class="span" colspan="5">
			<asp:DropDownList ID="ComboBoxStatisticField" Width="200px" onchange="onStatisticFieldDropDownListChanged()" runat="server" />
		</td>
	</tr>
	
	<tr class="statisticfield" style="display:none">
		<td colspan="6"><hr /></td>
	</tr>
	
	<tr class="statisticfield" style="display:none">
		<td class="c1"><%=Resources.Statistic.PropertyLabel %>: </td>
		<td class="c2"><My:TextBox ID="TextBoxHeaderText" runat="server" /></td>
		<td class="c1"><%=Resources.Statistic.Position %>: </td>
		<td id="RadioButtonListLocationTd" class="c2">
			<asp:RadioButtonList ID="RadioButtonListLocation" RepeatDirection="Horizontal" RepeatLayout="Flow" runat="server">
				<asp:ListItem Value="Column" Text="<%$ Resources:Statistic, Column%>" Selected="True" />
				<asp:ListItem Value="Row" Text="<%$ Resources:Statistic, Row%>" />
			</asp:RadioButtonList>
		</td>
		<td class="c1"><%=Resources.Statistic.Order %>: </td>
		<td class="c2"><My:IntegerTextBox ID="TextBoxOrdinal" runat="server" /></td>
	</tr>
	
	<tr class="statisticfield-string" style="display:none">
		<td colspan="6" style="padding-left: 28px; padding-top: 6px">
			<%=Resources.Statistic.MatchText %>: <My:TextBox ID="TextBoxStringValue" runat="server" />
		</td>
	</tr>
	
	<tr class="statisticfield-datetime" style="display:none">
		<td colspan="6" style="padding-left: 28px; padding-top: 6px">
			<%=Resources.Statistic.Between%>:
			<My:DatePicker ID="DatePickerStart" runat="server" />
			<span style="left: 130px; position:relative"><%=Resources.Statistic.To %></span>
			<span style="left: 140px; position:relative"><My:DatePicker ID="DatePickerEnd" runat="server" /></span>
		</td>
	</tr>

	<tr class="statisticfield-integer" style="display:none">
		<td colspan="6" style="padding-left: 28px; padding-top: 6px">
			<%=Resources.Statistic.Between%>:
			<My:IntegerTextBox ID="IntegerTextBoxMin" Width="80px" runat="server" />
			<%=Resources.Statistic.To %>
			<My:IntegerTextBox ID="IntegerTextBoxMax" Width="80px" runat="server" />
		</td>
	</tr>

	<tr class="statisticfield-decimal" style="display:none">
		<td colspan="6" style="padding-left: 28px; padding-top: 6px">
			<%=Resources.Statistic.Between%>:
			<My:DecimalTextBox ID="DecimalTextBoxMin" DecimalPrecision="2" Width="80px" runat="server" />
			<%=Resources.Statistic.To %>
			<My:DecimalTextBox ID="DecimalTextBoxMax" DecimalPrecision="2" Width="80px" runat="server" />
		</td>
	</tr>

	<tr class="statisticfield-singleselection" style="display:none">
		<td colspan="6" style="padding-left: 28px; padding-top: 6px">
			<%=Resources.Statistic.EqualsTo%>:
			<% /* the Uri of ComboBox is set in the detail panel */ %>
			<My:ComboBox ID="ComboBoxSelection" Mode="Remote" 
				ValueField="Value" TextField="Text" Method="GET"
				Editable="false" ForceSelection="true" Width="200px" runat="server" />
		</td>
	</tr>
	
	<tr class="statisticfield-aggregate" style="display:none">
		<td colspan="6" style="padding-left: 28px; padding-top: 6px">
			<%=Resources.Statistic.SumColumn %>: <asp:CheckBoxList ID="CheckBoxListAggregateColumns" RepeatDirection="Horizontal" RepeatLayout="Flow" runat="server" />
		</td>
	</tr>
</table>